<?php
/*
 * Created on Sep 4, 2007 by Gabriel Pratt
 * For LN2_database
 */
 //function makeBoxFooter() {
		$query = "select id, Tank, Tower, Position FROM Container ORDER BY Tank DESC, TOWER ASC, Position ASC";
		selectDatabase();
		$result = mysql_query($query) or die('Query failed: ' . mysql_error()); 
			while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$tableArray[$line['Tank']][$line['Tower']][$line['Position']] = $line['id'];
			}
			$select .="<table border= \"0\"> \n";
			
			//echo print_r($tableArray);
		foreach($tableArray as $tankName => $tank) {
			$select .= "	<tr> \n";
			$select .="	<td Valign=\"top\"> \n";
			$select .="	<table border=\"0\"><tr> \n";
			$select .= "		<tr> \n";
			$select .="		<td Valign=\"top\"> <a href=\"PrintBoxes.php?tank=$tankName\">$tankName </a></td> \n \n";
			$select .="		</tr> \n";
			$select .="		<tr> \n";
				
			foreach ($tank as $towerName => $tower) {
				$select .= "		<td Valign=\"top\">";
				$select .= "		<table border=\"2\"> \n"; 
				$select .="			<tr> \n";
				$select .= "			<th>Tower: <a href=\"PrintBoxes.php?tank=$tankName&tower=$towerName\">$towerName </a></th> \n";
				
					
				foreach ($tower as $position => $id) {
					
					
					$count = checkBox($id); //getting posted values
					if ($count > 0) {
						$count = "($count)";
						$color = "FFFF00";
					} else {
						$count = "";
						$color = "FFFFFF";
					}
					$links = $_GET;
					$links['ContainerID'] = $id;
					$search = makeSearchLink($links);
					
						
					$select .="				<tr> \n";
					$select .=" 				<td Valign=\"top\" bgcolor=\"$color\" > <a href=\"$caneLink?{$search}\"> Position: $position $count</a> \n";
					$select .="				</td> \n";
					$select .="				</tr> \n";
				
				
					}
					
					$select .="			</tr> \n";
					$select.= "		</table> \n";
					$select.="		</td>";
				}
				
				
				$select .= "		</tr> \n";
				$select .= "	</tr>";
				$select .="</table> \n";
				
	
			}
			
			$select .= "</table> \n";
			echo $select;
	//}
?>
